<?php
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");require_once("pwd1cls.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" type="text/javascript" src="../calendar/WdatePicker.js"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(image1/bg-body.png);	
}
td{
font-size:12px;
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg1.png"><img src="images/left-top-right1.png" width="17" height="29" /></td>
    <td width="100%" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">&nbsp;&nbsp;奖金查询</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.png"><img src="images/nav-right-bg.png" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg1.png">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
              <tr>
                <td align="center" class="left_bt2"><form name="form1" method="post" action="?action=query">
                  时间/：
                      <label>
                  <input name="time1" type="text" id="time1" size="8" onClick="WdatePicker()">
                  </label>
-
<input name="time2" type="text" id="time2" size="8" onClick="WdatePicker()">
<label>
<input type="submit" name="Submit" value="查询">
                    </label>
                </form></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="30"><table width="100%" height="60" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
              <tr>
                <td align="center" bgcolor="#f2f2f2" >日期</td>
                <?
				foreach($syssalaryary as $k1=>$v1){
				?>
                <td align="center" bgcolor="#f2f2f2" ><?=$v1?></td>
				<?
				}
				?>
                <td height="30" align="center" bgcolor="#f2f2f2" >总奖金</td>
                </tr>
				<tbody bgcolor="#FFFFFF">
<?
	   $syssalarystr='';
				  foreach($syssalaryary as $k1=>$v1){
				  	if ($syssalarystr!='') $syssalarystr.=',';$syssalarystr.=$k1;
				  }
	   
  $query='';
  if ($action=='query'){
	if(trim($time1)!='') $query.=" and datediff(from_unixtime(addtime,'%Y-%m-%d'),'{$time1}')>=0";
	if(trim($time2)!='') $query.=" and datediff(from_unixtime(addtime,'%Y-%m-%d'),'{$time2}')<=0";
  }
  $sql="select count(from_unixtime(addtime,'%Y-%m-%d')) as c from {$db_prefix}caiwu where userid='".$_SESSION["sys_userid"]."' and (ptype=3 or ptype=2 or ptype=4 or ptype=6 or ptype=7) and type in({$syssalarystr})";
  if ($query!='') $sql.=$query;
  $sql.=" group by from_unixtime(addtime,'%Y-%m-%d')";
  $rs1=$db->query($sql);
  $pageCount=0;
  while($rs=$db->fetch_array($rs1)){
    $pageCount++;
  }
  $page=new pagecls(20,intval($pageCount));
  $sql="select from_unixtime(addtime,'%Y-%m-%d') as tmpdate from {$db_prefix}caiwu where userid='".$_SESSION["sys_userid"]."' and (ptype=3 or ptype=2 or ptype=4 or ptype=6 or ptype=7) and type in({$syssalarystr})";
  if ($query!='') $sql.=$query;
  $sql.=" group by from_unixtime(addtime,'%Y-%m-%d')";
  $sql.=" order by from_unixtime(addtime,'%Y-%m-%d') desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);

  while($rs=$db->fetch_array($result)){
  	$allprice=0;$allincome=0;
  ?>
              <tr>
                <td align="center"><?=$rs['tmpdate']?></td>
                <?
				foreach($syssalaryary as $k1=>$v1){
				?>
                <td align="center">
				<?
				//荣衔奖
				$sqlj="select sum(price) as c from {$db_prefix}caiwu where userid='".$_SESSION['sys_userid']."' and type={$k1} and from_unixtime(addtime,'%Y-%m-%d')='".$rs['tmpdate']."' and (ptype=3 or ptype=2 or ptype=4 or ptype=6 or ptype=7)";
				$rsj=$db->get_one($sqlj);
				echo floatval($rsj['c']);
				$allprice+=floatval($rsj['c']);
				?>￥</td>
				<?
				}
				?>
                <td align="center"><?=$allprice?>￥</td>
                </tr>
               <?
  }
  $db->free_result($result);
  ?>
  </tbody>
            </table></td>
          </tr>
          <tr>
            <td height="30">&nbsp;</td>
          </tr>
          <tr>
            <td height="30" align="right">每页
              <?=$page->pagesize?>
              条 第
              <?=$page->pageno?>
              /
              <?=$page->pagenum?>
              页 共
              <?=$page->recnum?>
              条 <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a> <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a> <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a> <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
          </tr>
          <tr>
            <td height="30">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.png">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.png"><img src="images/buttom_left2.png" width="17" height="17" /></td>
    <td height="17" valign="top" background="images/buttom_bgs.png"><img src="images/buttom_bgs.png" width="17" height="17" /></td>
    <td background="images/mail_rightbg.png"><img src="images/buttom_right2.png" width="16" height="17" /></td>
  </tr>
</table>
</body>
</html>
